package crack_sda2;

import fem2.Constraint;
import fem2.MaterialModel;
import fem2.Mesh;
import fem2.MeshGenerator;
import fem2.MeshUtilities;
import fem2.Model;
import fem2.enu.State;
import fem2.material.StVenantKirchhoffMM;
import fem2.pre_and_post.GidMeshGenerator;

public abstract class AbstractLshapeWinklerUsingSDAElementDemo extends AbstractStructuralCrackDemo {

	public AbstractLshapeWinklerUsingSDAElementDemo() {
		projectDir = "/home/hbui/kratos_janosch";
		projectName = "LshapeWinkler.gid";
	}

	@Override
	public Mesh createMesh() {
		String fn = projectDir + '/' + projectName + '/' + meshFileName;
		MeshGenerator mg = new GidMeshGenerator(fn);
		Mesh mesh = mg.getMesh(2);
		return mesh;
	}

	@Override
	public Model createConditions(Model m) {
		Mesh mesh = m.getMesh();
		Constraint c1 = new Constraint(false, false);
		Constraint c2 = new Constraint(true, false);
		double du = -0.005;
		c2.setValue(1, du);
		mesh.setConstraint(c1, MeshUtilities.seekNodesOnSurface(mesh, 0, 1, -500));
		MeshUtilities.seekNode(mesh, 500, 250).setConstraint(c2);
		return m;
	}

	@Override
	public MaterialModel createMaterial(Model m) {
		double E = 25850;
		double nu = 0.18;
		double t = 100;
		State ss = State.PLANE_STRESS;
		MaterialModel mm = new StVenantKirchhoffMM(E, nu, t, 0, ss);
		return mm;
	}

	// @Override
	// public Node[] getNodesForResistantObserver(Model m) {
	// Node n = MeshUtilities.seekNode(m.getMesh(), 250, 1000);
	// return new Node[] { n };
	// }

}
